import motor.motor_asyncio
import asyncio
from sanic import Sanic, response

client = motor.motor_asyncio.AsyncIOMotorClient('localhost',27017)
db = client.test

async def do_insert():
    document = {"key": "value"}
    result = await db.test_collection.insert_one(document)
    print("result %s" % repr(result.inserted_id))
    
async def do_find():
    result1 = await db.temp.find_one({"workNo": "4844456539940978689"})
    result2 = await db.temp.find_one({"workNo": "4844456550653231105"})
    result3 = await db.temp.find_one({"workNo": "4844456553236922369"})
    print(result1)
    print(result2)
    print(result3)

app = Sanic(__name__)

@app.route("/")
async def start(request):
    do_find()
    # print(a)
    # a, b, c = do_find()
    # print(a)
    # print(b)
    # print(c)
    return response.json({
        "temp": "temp"
    })

if __name__ == "__main__":
    app.run("localhost", port=8888, debug=True, auto_reload=True)